import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {_HttpClient} from '@delon/theme';
import {Business} from './business';

@Injectable()
export class BusinessService {
    url_business_info = 'business/info';
    url_business_save = 'business/save';
    url_business_del = 'business/del';
    url_business_show = 'business/show';

    constructor(private http: _HttpClient) {
    }

    getBuiness(): Observable<Business> {
        return this.http.get(this.url_business_info);
    }

    updateBusiness(bussiness: Business): Observable<string> {
        return this.http.post(this.url_business_save, JSON.stringify(bussiness));
    }

    delBusiness(id: number): Observable<string> {
        return this.http.delete(this.url_business_del, {id: id});
    }

    showBusiness(id: number): Observable<Business> {
        return this.http.get(this.url_business_show, {id: id});
    }
}
